/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.meta;

import java.util.Date;

/**
 *
 * @author TrungHieu
 */
public class FileSlot {
	
	public static final String KEY_FILENAME = "file name";
	public static final String KEY_FILESIZE = "size";
	public static final String KEY_STATUS = "status";
	public static final String KEY_DOWNSPD = "down spd.";
	public static final String KEY_UPSPD = "up spd.";
	public static final String KEY_DOWNLOADED = "downloaded";
	public static final String KEY_UPLOADED = "uploaded";
	public static final String KEY_EST_TIME = "est. time";
	public static final String KEY_UD_RATIO = "U/D ratio";
	

	private int fileID;
	private String fileName;
	private String filePath;
	private long fileSize;
	private String status;
	private long downSpeed, upSpeed;
	private long estTime;
	private long downloaded, uploaded;
	private double updownRatio;
//	private Date dateStarted, dateLastTry;
	private String fileDesc;

	public FileSlot( int fileID, String fileName, String filePath, long fileSize, String status, double updownRatio, String fileDesc ) {
		this.fileID = fileID;
		this.fileName = fileName;
		this.filePath = filePath;
		this.fileSize = fileSize;
		this.status = status;
		this.downSpeed = 0;
		this.upSpeed = 0;
		this.downSpeed = 0;
		this.uploaded = 0;
		this.updownRatio = updownRatio;
		this.fileDesc = fileDesc;
	}

	public void setDownSpeed( long downSpeed ) {
		this.downSpeed = downSpeed;
	}

	public void setDownloaded( long downloaded ) {
		this.downloaded = downloaded;
	}

	public void setStatus( String status ) {
		this.status = status;
	}

	public void setUpSpeed( long upSpeed ) {
		this.upSpeed = upSpeed;
	}

	public void setUploaded( long uploaded ) {
		this.uploaded = uploaded;
	}

	public long getDownSpeed() {
		return downSpeed;
	}

	public long getDownloaded() {
		return downloaded;
	}

	public long getEstTime() {
		if (downSpeed == 0) {
			return Long.MAX_VALUE;
		}
		return ( long ) ( fileSize - downloaded ) / downSpeed;
	}

	public String getFileDesc() {
		return fileDesc;
	}

	public int getFileID() {
		return fileID;
	}

	public String getFileName() {
		return fileName;
	}

	public long getFileSize() {
		return fileSize;
	}

	public String getStatus() {
		return status;
	}

	public long getUpSpeed() {
		return upSpeed;
	}

	public double getUpdownRatio() {
		if (downloaded == 0){
			return 0;
		}
		return 0.001 * Math.round( uploaded / downloaded * 1000 );
	}

	public long getUploaded() {
		return uploaded;
	}
	
	public String getFilePath(){
		return filePath;
	}
}
